function gcUntil(name, condition) {
    if (typeof name === 'function') {
        condition = name;
        name = undefined;
    }
    return new Promise((resolve, reject) => {
        let count = 0;

        function gcAndCheck() {
            setTimeout(() => {
                count++;
                // todo: 需要触发gc
                //global.gc();
                if (condition()) {
                    resolve();
                } else if (count < 10) {
                    gcAndCheck();
                } else {
                    reject(name === undefined ? undefined : 'Test ' + name + ' failed');
                }
            }, 0);
        }

        gcAndCheck();
    });
}

function mustCall(fn, exact) {
    return _mustCallInner(fn, exact, 'exact');
}


export default {
    gcUntil
}